package org.jdpf.core.netvalidator;

import org.jdpf.core.kernel.elements.Net;
import org.jdpf.core.kernel.exceptions.CoreException;
import org.jdpf.core.kernel.execution.NetValidatorExecutor;
import org.jdpf.core.kernel.logging.AbstractLoggingService;
import org.jdpf.core.kernel.logging.ILoggable;
import org.jdpf.core.netvalidator.service.NetValidationService;

public class NetValidator extends AbstractLoggingService implements NetValidationService, ILoggable {
	
	public void validateNetStatically(Net net) throws CoreException {
		StaticNetValidator snv = new StaticNetValidator();
		try {
			snv.validateNetStatically(net);
		} catch (CoreException e) {
			net.setValid(false);
			logger.error(this, net.getName(), e.getMessage());
			throw e;
		}
	}
	
	public void validateNetDynamically(NetValidatorExecutor netExecutor) throws CoreException {
		DynamicNetValidator dnv = new DynamicNetValidator();
		try {
			dnv.validateNetDynamically(netExecutor);
		} catch (CoreException e) {
			netExecutor.getNet().setValid(false);
			logger.error(this, netExecutor.getNet().getName(), e.getMessage());
			throw e;
		}
	}
}
